If you’ve set up user accounts so that other people
on your network can access your computer, by default those users can
view and use your shares any time of day. That’s not usually a problem,
but you may want to prevent users from logging on at certain times. For
example, if you work with a particular shared folder each afternoon, you
might not want users accessing that folder until you’re done.
Windows 7 enables you to
specify the days of the week and hours of the day that a particular
user is allowed to log on to your system. When the user attempts to
access your computer over the network outside of those hours, he or she
sees a dialog box similar to the one shown in Figure 1.
The next couple of sections show you how to work with this feature.
Setting a User’s Logon Hours
Unfortunately, Windows 7
doesn’t have a dialog box or other interface that you can use to set
logon hours for a user. Instead, you must use a Command Prompt session
where you enter a command using the following general syntax:
net user username /times:day1,times1;day2,times2,...
username | The name of the user account you want to work with. |
day1, day2 | The
day of the week that the user is allowed to log on. You can spell out
the days, but it’s quicker to use the following codes (case doesn’t
matter): Su, M, T, W, Th, F, and Sa. You can also specify a range of days, such as M-F (for Monday to Friday). |
time1, time2 | For a given day, the time range that the user is allowed to log on. The range syntax is start-end, where start is the beginning of the logon hours, and end
is the end of the logon hours. You can either use 24-hour notation or
12-hour notation, although the latter means you must also specify AM and PM. |
Here are some examples:
net user karen /times:M-F,9AM-5PM
net user steve /times:M,18-24
net user emily /times:Sa,10PM-6PM; Su,12PM-6PM
Tip
If you’ve previously set a
user’s logon hours, you may decide later to remove those restrictions.
To give a user access at all times, use the all parameter:
To give a user no access, use no parameters:
Follow these steps to specify logon hours for a user:
1. | Select Start and type command.
|
2. | In
the search results, right-click Command Prompt, and then click Run as
Administrator. The User Account Control dialog box appears.
|
3. | Enter your UAC credentials to continue. Windows 7 opens an administrator Command Prompt session.
|
4. | Type your net user /times command and press Enter. The NET USER command responds with The command completed successfully.
|
5. | Repeat step 4 to specify all the logon hours you want to implement.
|
6. | Type exit and press Enter to close the Command Prompt session.
|
Automatically Logging Off a User When the Logon Hours Expire
By default, Windows 7 does
nothing if a user is currently logged on to your computer and that
person’s logon hours expire. In other words, there’s nothing to prevent a
teenager from hanging out online all night instead of doing homework!
To fix this, you can configure Windows 7 to automatically log off the
user when the account’s logon hours are over. Here are the steps to
follow:
Note
These steps require
the Local Security Policy snap-in, which is available only with Windows 7
Professional, Enterprise, and Ultimate.
1. | Select Start, type secpol.msc, and press Enter. The Local Security Policy window appears.
|
2. | Open the Security Settings, Local Policies, Security Options branch.
|
3. | Double-click the Network Security: Force Logoff When Logon Hours Expire policy.
|
4. | Click the Enabled option, as shown in Figure 2.
|
5. | Click OK.
|